The present invention relates to a pipeline microprocessor comprising a program counter, a circuit for the incrementation of the program counter, means to decode a set of instructions of the microprocessor comprising means to decode a conditional jump instruction of the program counter and a computation unit comprising a first output to deliver a result and a second output to deliver status bits of the result.
The present invention also relates to the execution of a conditional jump instruction in a pipeline microprocessor of the above type.
The term xe2x80x9cconditional jump instructionxe2x80x9d refers in the present application to a jump instruction JMPc from the program counter PC of a microprocessor whose execution depends on the result of a previous instruction. For example, the following instructions are conditional jumps:
1) JMPc IF C=0 VAL (jump with a value VAL if C=0),
2) JMPc IF N=0 VAL (jump with a value VAL if N=0),
3) JMPc IF P=0 VAL (jump with a value VAL if P=0),
4) JMPc IF Z=0 VAL (jump with a value VAL if Z=0),
the bit C (xe2x80x9ccarryxe2x80x9d) being the sum carry bit (or overflow bit), the bit N being the sign bit, the bit P being the parity bit and the bit Z being the zero value bit of the result of an operation performed by an arithmetic and logic computation unit ALU. These bits C, N, P, Z or flags are conventionally stored in a register called Rf (xe2x80x9cflags registerxe2x80x9d).
In the prior art, a conditional jump instruction cannot be executed before the result of the previous instruction is known and before the register Rf containing the flags is updated. This necessity contradicts the fact that, in a pipeline microprocessor, the steps of processing two successive instructions overlap one another with a shift of one rank. By way of example, we shall consider the following program sequence:
(1) (ADR1) SUB R1,R2,R3
(2) (ADR2) JMPC IF Z=1 VAL,
which means:
(1) xe2x80x9csubtract the contents of a register R3 from the contents of a register R2 and record the result in a register R3xe2x80x9d,
(2) xe2x80x9cjump program to address ADR2+VAL if the result is zero, else go to immediately following address ADR3 of the programxe2x80x9d,
and implies the processing steps described here below, each step being performed in one clock cycle:
1.1xe2x80x94reading of the instruction SUB at the address ADR1 of the program memory of the microprocessor, and incrementation of the program counter PC (ADR1 becomes ADR2),
1.2xe2x80x94decoding of the instruction SUB,
1.3xe2x80x94reading of the registers R2 and R3,
1.4xe2x80x94subtraction by the unit ALU of the contents of the register R3 from the contents of the register R2,
1.5xe2x80x94recording of the result of the subtraction in the register R1 and recording in the register Rf of the flags C, N, P, Z delivered by the unit ALU,
2.1xe2x80x94reading of the instruction JMPc at the address ADR2 and normal incrementation of the program counter (ADR2 becomes ADR3),
2.2xe2x80x94decoding of the instruction JMPc,
2.3xe2x80x94reading of the flag z in the register Rf; if Z=1, computation of the address ADR2+VAL and loading of this address in the program counter PC.
In a pipeline processing chain, the steps 1.x and 2.x here above should be processed simultaneously with a one-rank shift. However, it can be seen that the step 2.3 cannot overlap the step 1.4 because the result of the previous operation is not yet available in the register Rf. Also, a new instruction following the instruction JMPc cannot be read before the step 2.3 of the instruction JMPc has ended because it is not yet known at what address this instruction has to be read.
Thus, the standard approach to overcome this drawback consists in suspending the injection of a new instruction into the pipeline chain until the flags C, N, P, Z are loaded into the register Rf (step 1.5) and the conditional jump instruction is processed (step 2.3).
This method has the drawback of temporarily blocking the working of the pipeline chain and slowing down the performance of a program. Generally, the time lost for the execution of a program is proportional to the number of conditional jumps that the program contains.
The main goal of the present invention is to provide for a pipeline microprocessor structure for the execution of a conditional leap instruction without interruption of the pipeline processing chain.
The document U.S. Pat. No. 5,349,671, with reference to its FIGS. 1 to 4, describes a microprocessor comprising four pipeline stages, respectively for the reading of an instruction, the decoding of the instruction, the execution of the instruction and the storage of the result, as well as means for the decoding [3a, 3b] and execution [6a, 6b] of a conditional jump instruction. T he decoding means [3a, 3b] are connected both to the state register [2] of the microprocessor and to the output of the computation unit ALU [4] which delivers the flags of the microprocessor. More particularly, these decoding means comprise a first circuit [3a] for the evaluation of a call address, connected to the state register [2], a second circuit [3b] for the evaluation of a call address, connected to the above-mentioned output of the unit ALU and a flag-updating detector whose output indicates whether or not the instruction being executed is capable of modifying the flags of the microprocessor. When a conditional jump instruction is decoded, the choice of the read address of the following instruction is entrusted is entrusted to the first [3a] or second [3b] evaluation circuit according to the indication given by the flag-updating detector.
The present invention seeks an alternative to this conventional pipeline microprocessor structure and is aimed especially at providing means for the decoding and processing of a conditional jump instruction that is simpler than those described here above.
A secondary goal of the present invention is to provide a pipeline microprocessor structure that is simple and consumes little current.
To attain these goals, the present invention provides for a microprocessor of the type mentioned here above in which the computation unit and the means for decoding the conditional jump instruction are laid out in two neighboring pipeline stages, and the means for decoding the conditional jump instruction are connected to the second output of the computation unit.
According to one embodiment, the microprocessor comprises a first pipeline stage and a second pipeline stage, each comprising a first sector and a second sector, the first sector of each stage being active during a first clock half-cycle and the second sector of each stage being active during a second clock half-cycle.
According to one embodiment, the means of decoding the conditional jump instruction are laid out in the first sector of the first pipeline stage and the computation unit is laid out in a first sector of the second pipeline stage.
According to one embodiment, the means for decoding the conditional jump instruction are laid out in the second sector of the first pipeline stage and the computation unit is laid out in the first sector of the second pipeline stage.
According to one embodiment, the incrementation circuit of the program counter is laid out in the second sector of the first pipeline stage.
Advantageously, the microprocessor has a bank of registers belonging in read mode to the first sector and in write mode to the second sector of the second pipeline stage. This characteristic makes it possible to simplify the structure of the microprocessor which may have only two pipeline stages, providing for greater efficiency in electrical consumption, and the execution of compact instructions comprising only one operational code, the address of a source register and the address of a destination register of the result of the operation designated by the instruction.
According to one embodiment, the sectors of the second pipeline stage are demarcated by a tristate buffer laid out between the first and second outputs of the computation unit and write inputs of the bank of registers.
According to one embodiment, the conditional jump instruction is a relative jump instruction. The means of incrementation of the program counter comprise an adder circuit receiving, at input, the current value of the program counter and the output of a multiplexer circuit, the multiplexer circuit is driven by the means for decoding the conditional jump instruction and receives, at input, a normal incrementation value of the program counter and a relative jump value of the program counter, contained in the conditional jump instruction.
According to one embodiment, the conditional jump instruction is an absolute jump instruction, the means of incrementation of the program counter comprise a multiplexer circuit receiving, at input, the output of an address circuit and an absolute jump value of the program counter contained in the conditional jump instruction, the multiplexer circuit is driven by means for decoding the conditional jump instruction, and the adder circuit receives, at input, the current value of the program counter and a normal incrementation value of the program counter.
According to one embodiment, the decoding means are laid out to decode a compact conditional jump instruction comprising an operation code, a condition and a jump value.